[#import "/view/lib/tableform.ftl" as tableform]
[@main.layout title="form-demo#2 - index"]

<h1>Form Demo #2</h1>

<p>This is a typical user registration form. The controller will validate the inputs and make values sticky so that
when failed, fields are repopulated. Values are simply rediplayed after process; nothing is persistent.</p>

[#if submitSuccessful??]
<p>FormValues from a successful submit.</p>
<table class="twocols">
	[#list formData.multiValues?keys as fieldName]
	<tr class="[#if fieldName_index % 2 ==0]odd[#else]even[/#if]">
		<td>${formData.fields[fieldName].label}</td>
		<td>
			<ul style="color: blue; list-style-type: none">
				[#list formData.multiValues[fieldName] as value]
				<li>${value}</li>
				[/#list]
			</ul>
		</td>
	</tr>
	[/#list]
</table>
<hr/>
[/#if]

<div style="width: 800px;">
[@tableform.form]
	[@tableform.input type="text" name="username" /]
	[@tableform.input type="password" name="password" /]
	[@tableform.input type="password" name="cpassword" /]
	[@tableform.input type="text" name="email" /]
	[@tableform.input type="text" name="firstName" /]
	[@tableform.input type="text" name="lastName" /]
	[@tableform.submit value="Process Form" /]
[/@tableform.form]
</div>

[/@main.layout]
